package org.flowable.pz.enums;

import lombok.Getter;
import org.flowable.pz.exception.FlowableCustomException;

/**
 * 流程实例状态枚举定义
 * */
@Getter
public enum FlowableStatusEnum {

    ACTIVE(1,"运行中"),
    SUSPENDED(2,"已挂起"),
    COMPLETED(3,"已完成"),
    TERMINATED(4,"已终止"),
    DELETED(5,"已删除");

    FlowableStatusEnum(int status, String description){
        this.status = status;
        this.description = description;
    }
    private final String description;
    private final int status;

    public static FlowableStatusEnum getByCode(int code){
        for(FlowableStatusEnum item : values()){
            if(item.status == code){
                return item;
            }
        }
        throw new FlowableCustomException("流程实例无效的状态码：" + code);
    }

    public static FlowableStatusEnum getByEndAndActive(){
        return null;
    }
}
